package com.sdehl.kafkatransfer.constant.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * @author Jiax
 * @version 1.0.0
 * @description: PlateColorEnum
 * @date 2023-10-13 14:52
 */
@Getter
public enum VehicleColorEnum {

    WHITE(1,"A","白色","white"),
    GRAY(2,"B","灰色","gray"),
    YELLOW(3,"C","黄色","yellow"),
    PINK(4,"D","粉色","pink"),
    RED(5,"E","红色","red"),
    PURPLE(6,"F","紫色","purple"),
    GREEN(7,"G","绿色","green"),
    BLUE(8,"H","蓝色","blue"),
    BROWN(9,"I","棕色","brown"),
    BLACK(10,"J","黑色","black"),
    OTHER(99,"Z","未知","unknown"),
    ;
    /**
     * 编码
     */
    private Integer code;
    /**
     * 编码（字母）
     */
    private String code2;
    /**
     * 中文名称
     */
    private String name;
    /**
     * 英文名称
     */
    private String enName;

    VehicleColorEnum(Integer code,String code2, String name, String enName) {
        this.code = code;
        this.code2 = code2;
        this.name = name;
        this.enName = enName;
    }

    /**
     * 根据code查询车牌颜色枚举
     * @param code
     * @return
     */
    public static VehicleColorEnum getByCode(Integer code) {
        for (VehicleColorEnum vehicleColor : values()) {
            if (Objects.equals(vehicleColor.getCode(), code)) {
                return vehicleColor;
            }
        }
        return null;
    }

    /**
     * 根据code查询颜色
     * @param code
     * @return
     */
    public static String getEnNameByCode(Integer code) {
        for (VehicleColorEnum vehicleColor : values()) {
            if (Objects.equals(vehicleColor.getCode(), code)) {
                return vehicleColor.getEnName();
            }
        }
        return null;
    }

}
